<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>添加</title>


<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/amazeui.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/app.css">
<link
	href="${pageContext.request.contextPath}/style/css/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/style/layui/css/layui.css"
	rel="stylesheet">
<script src="${pageContext.request.contextPath}/style/js/jquery.min.js"></script>
<script
	src="${pageContext.request.contextPath}/style/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/style/js/amazeui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/style/layui/layui.js"></script>
</head>

<body>

	<form id="form" class="layui-form" action="#">
	<input type="hidden" name="menuId" value="${menu.menuId }">
		<br>
		<div class="layui-form-item">
			<label class="layui-form-label">菜单名</label>
			<div class="layui-input-block">
				<input type="text" value="${menu.menuName}" name="menuName"
					style="width:250px" required lay-verify="required"
					placeholder="请输入菜单名" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">父节点</label>
			<div class="layui-input-block" style="width:250px">
				<select name="menuParentid" lay-verify="required">
					<option value="0">无(一级菜单)</option>
					<c:forEach var="m" items="${menulist }">
						<option value="${m.menuId }">${m.menuName}</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">URL</label>
			<div class="layui-input-block">
				<input type="text" name="menuUrl" value="${menu.menuUrl }"
					style="width:250px" required placeholder="请输入URL"
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label" style="position: absolute;left:0px">顺序</label>
			<div class="layui-input-block" style=" width:250px">
				<input type="text" name="menuOrder" value="${menu.menuOrder }"
					style="width:250px" required lay-verify="required|number"
					placeholder="请输入菜单的顺序" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-block" style="width:250px">
				<select name="menuState" lay-verify="required">
					<c:forEach var="code" items="${codelist }">
						<option value="${code.codeValue }">${code.codeName}</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button lay-submit class="btn btn-primary" lay-filter="go" id="sub">确定</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>

	</form>

</body>
<script type="text/javascript">
	layui.use('form', function() {
		var form = layui.form;

		form.on('submit(go)', function(data) {
			addproc();
			return false;
		});
		function addproc() {
			$.ajax({
				type : "POST",
				url : "${pageContext.request.contextPath}/menu/editproc",
				data : $("#form").serialize(),
				dataType : "text",
				success : function(res) {
					if (res == "success") {
						layui.use('layer',
								function() {
									var layer = layui.layer;
									var index = parent.layer
											.getFrameIndex(window.name);
									layer.alert('菜单修改成功', {
										skin : 'layui-layer-molv' //样式类名
										,
										closeBtn : 0
									}, function() {
										parent.layer.close(index);
									});
								});
					} else {
						alert("菜单修改失败");
					}
				},
				error : function() {
					alert("error");
				}

			});
		}

	});
</script>
<script type="text/javascript">
$(document).ready(
		function() {
			 $("[name='menuParentid'] option[value='${menu.menuParentid }']").attr("selected","true");
			 $("[name='menuState'] option[value='${menu.menuState}']").attr("selected","true");

			//form.render();
		});
 
</script>
</html>
